package vn.bang.communication;

import vn.bang.communication.Command.CommandName;

public class CommandBuilder {

	private Command command;
	
	public void buildLogin(String username, String password) {
		String statement = String.format("%s %s %s", CommandName.LOGIN.toString(), username, password);
		command = new Command(statement);
	}
	
	public void buildNewBoard(long hostId, long playerId) {
		String statement = String.format("%s %d %d", CommandName.NEW_GAME.toString(), hostId, playerId);
		command = new Command(statement);
	}
	
	public void buildMove(long boardId, int toColumnIndex, int toRowIndex) {
		String statement = String.format("%s %d %d %d", CommandName.MOVE.toString(), boardId, toColumnIndex, toRowIndex);
		command = new Command(statement);
	}
	
	public Command toCommand() {
		return command;
	}
	
	@Override
    public String toString() {
		if (null != command) {
			return command.toString();
		}
		return "";
    }
	
}
